Introduction
Overview
The Fake Reader is a utility designed exclusively for testing and development purposes, providing a way to simulate card reader behavior in controlled scenarios. This tool enables developers to simulate various card reader actions, test transaction flows, and configure predefined or custom behaviors.
It exists to facilitate robust testing of card reader interactions, simulating real-world scenarios without needing physical hardware. It helps developers:
- Test different transaction flows (e.g., approved, declined).
- Simulate various card types (e.g., contact, contactless, magnetic stripe).
- Experiment with predefined and custom behaviors to ensure the correct implementation of the SDK in various scenarios.
The Fake Reader should only be used for testing and development. Any transaction attempts in production environments will be rejected. Additionally, the Fake Reader currently does not support interactions with the configurator or printer. It is designed specifically for simulating transactions.
Installation
Add the following dependency to your build.gradle
file to include the Fake Reader in your project:
dependencies {
implementation "com.geopagos.payments.sdk:sdk-reader-fake:$paymentVersion"
}
Configuration
Initialize the Fake Reader in your application code by providing an implementation of the SDKFakeActionRequestCallback
interface:
SDKFakeInstallerProvider.getInstaller(
listener = object : SDKFakeActionRequestCallback { // <LISTENER_FAKE_READER_ACTION_REQUEST>
override fun onActionRequired(readerActionRequest: SDKFakeReaderActionRequest) {
// Handle the specific fake reader action requests here.
}
}
)
- LISTENER_FAKE_READER_ACTION_REQUEST is an implementation of the SDKFakeActionRequestCallback interface. This listener handles the fake reader's action requests during the testing flow.
If you wish to change the behavior defined during initialization, you must perform a
release
of the SDK and reinitialize it with the new behavior.
SDKFakeCard
The SDKFakeCard
class is a sealed structure that defines the characteristics and behaviors of fake cards used in card reader simulations during a transaction. It allows modeling different types of cards, such as magnetic stripes and EMV cards (contact or contactless), providing a flexible and organized way to handle multiple testing scenarios.
Transactions performed in lower environments using this reader will be reflected in Geopagos APIs but linked to a fixed card number, regardless of the card number parameterized here. The PAN configured here impacts the BINs displayed in the
SDKTransactionCard
class and the interaction with plugins like thebinCvmContactlessDecider
.
Magnetic Card (Magnetic
)
The Magnetic
class represents a magnetic stripe card. It inherits from the SDKFakeCard
class and includes all its attributes:
brand
(SDKFakeCardBrand
): The brand of the card (e.g., Visa, MasterCard, Amex).cardNumber
(String
): The card's primary account number (PAN).serviceCode
(String
): A code that specifies the services supported by the card.expireDate
(String
): The expiration date of the card inMMYY
format.
val magneticCard = SDKFakeCard.Magnetic(
brand = SDKFakeCardBrand.Visa,
cardNumber = "4111111111111111",
serviceCode = "101",
expireDate = "0526"
)
EMV Contact Card (Emv.Contact
)
The Emv.Contact
class represents an EMV card that uses contact-based interactions.
brand
(SDKFakeCardBrand
): The brand of the card (e.g., Visa, MasterCard, Amex).cardNumber
(String
): The card's primary account number (PAN).serviceCode
(String
): A code that specifies the services supported by the card.expireDate
(String
): The expiration date of the card inMMYY
format.cvmResult
(SDKCvmResult
): The Cardholder Verification Method result (e.g., PIN, No CVM, Signature).availableEmvApps
(List<SDKFakeEmvApp>
): A list of EMV applications available on the card.
val contactEmvCard = SDKFakeCard.Emv.Contact(
brand = SDKFakeCardBrand.MasterCard,
cardNumber = "5555555555554444",
serviceCode = "202",
expireDate = "0427",
cvmResult = SDKCvmResult.PIN,
availableEmvApps = listOf(
SDKFakeEmvApp(app = "APP1", appName = "APP1"),
SDKFakeEmvApp(app = "APP2", appName = "APP2"),
SDKFakeEmvApp(app = "APP3", appName = "APP3" )
)
)
EMV Contactless Card (Emv.Contactless
)
The Emv.Contactless
class represents an EMV card that uses contactless (NFC) interactions.
brand
(SDKFakeCardBrand
): The brand of the card (e.g., Visa, MasterCard, Amex).cardNumber
(String
): The card's primary account number (PAN).serviceCode
(String
): A code that specifies the services supported by the card.expireDate
(String
): The expiration date of the card inMMYY
format.cvmResult
(SDKCvmResult
): The Cardholder Verification Method result (e.g., PIN, No CVM, Signature).
val contactlessEmvCard = SDKFakeCard.Emv.Contactless(
brand = SDKFakeCardBrand.Visa,
cardNumber = "4111111111111111",
serviceCode = "101",
expireDate = "0628",
cvmResult = SDKCvmResult.NO_CVM
)